From: Dario Faggioli Date: Fri, 16 Feb 2018 18:38:48 +0000 (+0100) Subject: tools: libxenstat: fix format string overflow X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~559 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=8f9ccfe93570ecae18d9cc224931787d0bca9c66;p=xen.git tools: libxenstat: fix format string overflow With gcc 7.3.0, the build fails like this: src/xenstat_linux.c: In function ‘getBridge’ src/xenstat_linux.c:78:34: warning: ‘%s’ directive writing up to 255 bytes into a region of size 241 [-Wformat-overflow=] sprintf(tmp, "/sys/class/net/%s/bridge", de->d_name); ^~ src/xenstat_linux.c:78:5: note: ‘sprintf’ output between 23 and 278 bytes into a destination of size 256 sprintf(tmp, "/sys/class/net/%s/bridge", de->d_name); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix by making the buffer bigger. Signed-off-by: Dario Faggioli Acked-by: Wei Liu --- diff --git a/tools/xenstat/libxenstat/src/xenstat_linux.c b/tools/xenstat/libxenstat/src/xenstat_linux.c index 907d65fa63..7cdd3bf91f 100644 --- a/tools/xenstat/libxenstat/src/xenstat_linux.c +++ b/tools/xenstat/libxenstat/src/xenstat_linux.c @@ -69,7 +69,7 @@ void getBridge(char *excludeName, char *result, size_t resultLen) struct dirent *de; DIR *d; - char tmp[256] = { 0 }; + char tmp[512] = { 0 }; d = opendir("/sys/class/net"); while ((de = readdir(d)) != NULL) {